Skip to main content

dayofweek

dayofweek

Description

Syntax:

INT DAYOFWEEK (DATETIME date)

This function returns the index value of the day of week based on the date (Sunday = 1, Monday = 2, and Saturday = 7).

The parameter is of DATE or DATETIME type.

Example

mysql> select dayofweek('2019-06-25');
+----------------------------------+
| dayofweek('2019-06-25 00:00:00') |
+----------------------------------+
| 3 |
+----------------------------------+

mysql> select dayofweek(cast(20190625 as date));
+-----------------------------------+
| dayofweek(CAST(20190625 AS DATE)) |
+-----------------------------------+
| 3 |
+-----------------------------------+

Keywords

DAYOFWEEK